package com.hare.harelearn.Java.Aop.动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @program: HareLearn
 * @description:
 * @author: Hare
 * @create: 2024−12-03 16:43
 * @Version 1.0
 **/
public class JdkProxy implements InvocationHandler {

    TargetService targetService;

    public JdkProxy(TargetService targetService) {
        this.targetService = targetService;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("房东交给中介");
        method.invoke(targetService,args);
        System.out.println("中介租了房子，收钱了");
        return null;
    }
}
